﻿#include "../../ctlColorDefine.h"

#define SWAP_COLOR(prefix)	\
	prefix.stay.swap();	\
	prefix.down.swap();	\
	prefix.leave.swap();	\
	prefix.disenable.swap();

namespace swui
{
	void ctlStyleGradient::set(_subType subType)
	{
		smooth.enterLeave = 1000;
		switch(subType)
		{
		case green:
			set(common);
			fill.down.set(0xffe3ffe0, 0xff8ef886);
			border.down.set(0xffaaceae, 0xff73b075);
			selectFill.stay.set(0xffe0fcdd, 0xff88ed80);
			changeToCommon();
			break;
		case yellow:
			set(common);
			fill.down.set(0xfffbffe0, 0xfff8ed6d);
			border.down.set(0xffb7baa3, 0xff80834b);
			selectFill.stay.set(0xfffbffe0, 0xfff7e730);
			changeToCommon();
			break;
		case purple:
			set(common);
			fill.down.set(0xffe5e6fe, 0xff9c93f6);
			border.down.set(0xff888bc6, 0xff6862a4);
			selectFill.stay.set(0xffd5d7fe, 0xff8a7fd2);
			changeToCommon();
			break;
		case orange:
			set(common);
			fill.down.set(0xffffefcd, 0xfffeb27f);
			border.down.set(0xfffe7e00, 0xffc46a00);
			selectFill.stay.set(0xffffdca9, 0xfffeb21f);
			changeToCommon();
			break;
		case common:
			//公共部分
			border.disenable.set(0xffb8b8b8, 0xffb8b8b8);
			border.down.set(0xff0099f9, 0xff0078c4);
			border.leave.set(0xff999999, 0xff474747);
			border.stay = border.down;
			fill.disenable.set(0xffeeeeee, 0xffe8e8e8);
			fill.down.set(0xffe2fefe, 0xffa2dafe);
			fill.leave.set(0xffffffff, 0xffd2d2d2);
			fill.stay = fill.leave;
			selectText.leave = selectText.stay = selectText.down =
				text.leave = text.stay = text.down = 0xff000000;
			text.disenable = selectText.disenable = 0xff777777;
			//Select 部分
			selectFill.disenable = fill.disenable;
			selectFill.down = fill.down;
			selectBorder.disenable = border.disenable;
			selectBorder.down = border.down;
			crSelectedFlag = 0xff000000;
			crDisenabledSelectedFlag = 0xff888888;
			selectBorder.stay.set(0xff22bbf9, 0xff229ae6);
			selectFill.stay.set(0xfff2fefe, 0xffc2eefe);
			selectBorder.leave = border.down;
			selectFill.leave = fill.down;
			break;
		}
		subStyle = subType;
	}
	ctlStyleGradient& ctlStyleGradient::swapFillDirection()
	{
		SWAP_COLOR(fill);
		return *this;
	}
	ctlStyleGradient& ctlStyleGradient::swapBorderDirection()
	{
		SWAP_COLOR(border);
		return *this;
	}
	ctlStyleGradient& ctlStyleGradient::swapStayFillDirection()
	{	
		SWAP_COLOR(selectFill);
		return *this;
	}
	ctlStyleGradient& ctlStyleGradient::swapStayBorderDirection()
	{	
		SWAP_COLOR(selectBorder);
		return *this;
	}
	ctlStyleGradient::ctlStyleGradient(_subType subType, 
		ctlGradientDirection gradir, 
		ctlColorFormat type) 
	{
		colorFormat = type;
		gradientDirection = gradir;
		styleType = ctlStyleType::gradient;
		set(subType);
	}
}